package cn.edu.njtc.mapper;

import cn.edu.njtc.entity.dto.ActivityQueryDto;
import cn.edu.njtc.entity.pojo.EducationActivity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

public interface EducationActivityMapper extends BaseMapper<EducationActivity> {
    @Select("<script>" +
            "SELECT * FROM tb_educational_activity " +
            "ORDER BY activity_date DESC" +
            "</script>")
    List<EducationActivity> selectAllActivities();
    @Update("UPDATE tb_educational_activity SET status = '进行中' " +
            "WHERE status = '未开始' AND activity_date <= #{now}")
    int updateStatusForStartedActivities(@Param("now") LocalDateTime now);

    @Update("UPDATE tb_educational_activity SET status = '已结束' " +
            "WHERE status = '进行中' AND activity_date <= #{cutoffTime}")
    int updateStatusForEndedActivities(@Param("cutoffTime") LocalDateTime cutoffTime);


}
